<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<!-- <form action="http://localhost:8080/postdemo" method="post"> -->
		<form action="http://localhost:8080/demo" method="post">
			<input type="text" name="account" />
			<input type="password" name="password" />
			<button type="submit">提交</button>
			<!-- <button type="button">提交</button> -->
		</form>
		<script src="../js/jquery-3.5.1.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$("button").click(function(){
				let account = $("input[name='account']").val();
				if(account.trim().length === 0) {
					console.log(1);
					return false;//如果按钮类型是submit，则事件必须返回false才会阻止
				}
				// $("form").submit();//表单提交
				//也可以通过ajax方式提交然后通过location.href进行跳转
			});
		</script>
	</body>
</html>
